import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core';
import {GnTreeDirective} from 'geminis-ng';
import {NzTreeComponent, NzTreeNode} from 'ng-zorro-antd/tree';

@Component({
  selector: 'everydata-category-tree',
  template: `
    <div style="display: flex; height: 100%;">
      <div style="width:20%;">
        <nz-tree gn-tree everydata-category-tree [showRoot]="showRoot" (initialed)="treeInitialed.emit(nzTree.getSelectedNodeList())"
                 (nzClick)="treeClick.emit(nzTree.getSelectedNodeList())"></nz-tree>
      </div>
      <nz-divider nzType="vertical" style="height: 100%"></nz-divider>
      <div style="width: 80%; padding-left: 1rem;">
        <ng-content></ng-content>
      </div>
    </div>
  `
})
export class CategoryTreeComponent {

  @ViewChild(GnTreeDirective, {static: true}) tree!: GnTreeDirective;
  @ViewChild(NzTreeComponent, {static: true}) nzTree!: NzTreeComponent;

  @Input() showRoot = false;

  @Output() treeClick = new EventEmitter<NzTreeNode[]>();
  @Output() treeInitialed = new EventEmitter<NzTreeNode[]>();

}

